package site.yunnong.atvris.portal.spider.haokan;

import com.geccocrawler.gecco.GeccoEngine;
import com.geccocrawler.gecco.annotation.Ajax;
import com.geccocrawler.gecco.annotation.Gecco;
import com.geccocrawler.gecco.annotation.RequestParameter;
import com.geccocrawler.gecco.request.HttpGetRequest;
import com.geccocrawler.gecco.spider.HtmlBean;
import lombok.Data;

/**
 * @author zjh
 * @date 2021/8/31 10:57
 */
@Data
@Gecco(matchUrl = "https://haokan.baidu.com/web/search/api?pn={pn}&rn=10&type=video&query={query}", pipelines = "haokanPagePipeline")
public class HaokanPage implements HtmlBean {
    
    @RequestParameter
    private String pid;
    
    @RequestParameter
    private String pn;
    
    @RequestParameter
    private String query;
    
    @Ajax(url = "https://haokan.baidu.com/web/search/api?pn={pn}&rn=10&type=video&query={query}")
    private HaokanRes res;

    public static void main(String[] args) {
        String url = "https://haokan.baidu.com/web/search/api?pn=1&rn=10&type=video&query=林木育种";
        HttpGetRequest start = new HttpGetRequest(url);
        start.addParameter("pid", "58");
        GeccoEngine.create()
                .classpath("site.yunnong.atvris.portal.spider.haokan")
                .seed(start)
                .thread(1)
                .interval(2000)
                .start();
    }
}
